-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
dict: on retrieval, key allowed to be null #14733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
It just came to me that this might have been a design decision as: a = {'A': 1}
b: dict[int | None, str] = {1: 'א'}
k1 = a.get('A')
k2 = b.get(k1) gives: > uv run --with pyright pyright .\dict-none-key.py
0 errors, 0 warnings, 0 informations I searched manually, and with copilot and found no direct mention... Is this PR acceptable in principal, which in that case I'll cross all the I's and dot all the T's |
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ... | ||
|
||
class dict(MutableMapping[_KT, _VT]): | ||
_KTN = _KT | None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type aliases defined like this are technically questionable, so let's just write _KT | None
where appropriate.
It's sort of questionable to me to treat |
IMHO only |
But